<!DOCTYPE html><html lang="[&quot;zh-Hans&quot;,&quot;zh-CN&quot;,&quot;default&quot;]"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"><meta name="description" content="两个mac之间快速传递文件"><meta name="keywords" content="电脑技能"><meta name="author" content="wenmu"><meta name="copyright" content="wenmu"><title>两个mac之间快速传递文件 | 温木的博客</title><link rel="shortcut icon" href="/melody-favicon.ico"><link rel="stylesheet" href="/css/index.css?version=1.6.1"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/font-awesome@latest/css/font-awesome.min.css?version=1.6.1"><link rel="dns-prefetch" href="https://cdn.staticfile.org"><link rel="dns-prefetch" href="https://cdn.bootcss.com"><link rel="dns-prefetch" href="https://creativecommons.org"><link rel="dns-prefetch" href="http://ta.qq.com"><script>(function() {
   var hm = document.createElement("script");
   hm.src = "https://tajs.qq.com/stats?sId=&lt;script type=&quot;text/javascript&quot; src=&quot;http://tajs.qq.com/stats?sId=66523541&quot; charset=&quot;UTF-8&quot;&gt;&lt;/script&gt;";
   var s = document.getElementsByTagName("script")[0];
   s.parentNode.insertBefore(hm, s);
 })();</script><script>var GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: undefined,
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  }
} </script><meta name="generator" content="Hexo 4.2.0"></head><body><i class="fa fa-arrow-right" id="toggle-sidebar" aria-hidden="true"></i><div id="sidebar"><div class="toggle-sidebar-info text-center"><span data-toggle="切换文章详情">切换站点概览</span><hr></div><div class="sidebar-toc"><div class="sidebar-toc__title">目录</div><div class="sidebar-toc__progress"><span class="progress-notice">你已经读了</span><span class="progress-num">0</span><span class="progress-percentage">%</span><div class="sidebar-toc__progress-bar"></div></div><div class="sidebar-toc__content"><ol class="toc"><li class="toc-item toc-level-3"><a class="toc-link" href="#1-电脑设置"><span class="toc-number">1.</span> <span class="toc-text">1.电脑设置</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#SCP-拷贝"><span class="toc-number">2.</span> <span class="toc-text">SCP 拷贝</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#使用实例"><span class="toc-number">3.</span> <span class="toc-text">使用实例</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#远程连接中文乱码"><span class="toc-number">4.</span> <span class="toc-text">远程连接中文乱码</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#乱码解决"><span class="toc-number">5.</span> <span class="toc-text">乱码解决</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#说明"><span class="toc-number">6.</span> <span class="toc-text">说明</span></a></li></ol></div></div><div class="author-info hide"><div class="author-info__avatar text-center"><img src="https://i.loli.net/2020/02/27/xwaBoOj158MfNyq.jpg"></div><div class="author-info__name text-center">wenmu</div><div class="author-info__description text-center">记录一些在工作中或学习新知识时学到的一些知识点；正所谓好记性不如一个烂笔头，温故而知新！</div><hr><div class="author-info-articles"><a class="author-info-articles__archives article-meta" href="/archives"><span class="pull-left">文章</span><span class="pull-right">115</span></a><a class="author-info-articles__tags article-meta" href="/tags"><span class="pull-left">标签</span><span class="pull-right">52</span></a><a class="author-info-articles__categories article-meta" href="/categories"><span class="pull-left">分类</span><span class="pull-right">30</span></a></div></div></div><div id="content-outer"><div class="no-bg" id="top-container"><div id="page-header"><span class="pull-left"> <a id="site-name" href="/">温木的博客</a></span><i class="fa fa-bars toggle-menu pull-right" aria-hidden="true"></i><span class="pull-right menus"><a class="site-page" href="/">首页</a><a class="site-page" href="/archives">文章</a><a class="site-page" href="/tags">标签</a><a class="site-page" href="/categories">分类</a></span></div><div id="post-info"><div id="post-title">两个mac之间快速传递文件</div><div id="post-meta"><time class="post-meta__date"><i class="fa fa-calendar" aria-hidden="true"></i> 2020-02-28</time><span class="post-meta__separator">|</span><i class="fa fa-inbox post-meta__icon" aria-hidden="true"></i><a class="post-meta__categories" href="/categories/%E7%94%B5%E8%84%91%E6%8A%80%E8%83%BD/">电脑技能</a></div></div></div><div class="layout" id="content-inner"><article id="post"><div class="article-container" id="post-content"><h3 id="1-电脑设置"><a href="#1-电脑设置" class="headerlink" title="1.电脑设置"></a>1.电脑设置</h3><p>两台笔记本都需要开通<strong>“远程登录”</strong>，设置步骤：</p>
<blockquote>
<p><code>系统偏好设置</code>-&gt;<code>共享</code>-&gt;<code>远程登录</code></p>
</blockquote>
<p>结果如图</p>
<p><img src="https://upload-images.jianshu.io/upload_images/1348523-b21af7583a4bbbbb.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="设置截图"></p>
<h3 id="SCP-拷贝"><a href="#SCP-拷贝" class="headerlink" title="SCP 拷贝"></a>SCP 拷贝</h3><blockquote>
<p>scp 是 secure copy 的简写，用于在 Linux 下进行远程拷贝文件的命令，和它类似的命令有 cp，不过 cp 只是在本机进行拷贝不能跨服务器，而且 scp 传输是加密的。可能会稍微影响一下速度。当你服务器硬盘变为只读 read only system 时，用 scp 可以帮你把文件移出来。另外，scp 还非常不占资源，不会提高多少系统负荷，在这一点上，rsync 就远远不及它了。虽然 rsync 比 scp 会快一点，但当小文件众多的情况下，rsync 会导致硬盘 I/O 非常高，而 scp 基本不影响系统正常使用。</p>
</blockquote>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line">1．命令格式：</span><br><span class="line">scp [参数] [原路径] [目标路径]</span><br><span class="line"></span><br><span class="line">2．命令功能：</span><br><span class="line">scp是 secure copy的缩写, scp是linux系统下基于ssh登陆进行安全的远程文件拷贝命令。</span><br><span class="line">linux的scp命令可以在linux服务器之间复制文件和目录。</span><br><span class="line"></span><br><span class="line">3．命令参数：</span><br><span class="line">-1  强制scp命令使用协议ssh1</span><br><span class="line">-2  强制scp命令使用协议ssh2</span><br><span class="line">-4  强制scp命令只使用IPv4寻址</span><br><span class="line">-6  强制scp命令只使用IPv6寻址</span><br><span class="line">-B  使用批处理模式（传输过程中不询问传输口令或短语）</span><br><span class="line">-C  允许压缩。（将-C标志传递给ssh，从而打开压缩功能）</span><br><span class="line">-p 保留原文件的修改时间，访问时间和访问权限。</span><br><span class="line">-q  不显示传输进度条。</span><br><span class="line">-r  递归复制整个目录。</span><br><span class="line">-v 详细方式显示输出。scp和ssh(1)会显示出整个过程的调试信息。这些信息用于调试连接，验证和配置问题。</span><br><span class="line">-c cipher  以cipher将数据传输进行加密，这个选项将直接传递给ssh。</span><br><span class="line">-F ssh_config  指定一个替代的ssh配置文件，此参数直接传递给ssh。</span><br><span class="line">-i identity_file  从指定文件中读取传输时使用的密钥文件，此参数直接传递给ssh。</span><br><span class="line">-l <span class="built_in">limit</span>  限定用户所能使用的带宽，以Kbit/s为单位。</span><br><span class="line">-o ssh_option  如果习惯于使用ssh_config(5)中的参数传递方式，</span><br><span class="line">-P port  注意是大写的P, port是指定数据传输用到的端口号</span><br><span class="line">-S program  指定加密传输时所使用的程序。此程序必须能够理解ssh(1)的选项。</span><br></pre></td></tr></table></figure>

<h3 id="使用实例"><a href="#使用实例" class="headerlink" title="使用实例"></a>使用实例</h3><ol>
<li>拷贝文件<br>命令格式：<br><code>scp local_file remote_username@remote_ip:remote_folder</code><br>或者<br><code>scp local_file remote_username@remote_ip:remote_file</code><br>或者<br><code>scp local_file remote_ip:remote_folder</code><br>或者<br><code>scp local_file remote_ip:remote_file</code></li>
</ol>
<p>第 1,2 个指定了用户名，命令执行后需要输入用户密码，第 1 个仅指定了远程的目录，文件名字不变，第 2 个指定了文件名</p>
<p>第 3,4 个没有指定用户名，命令执行后需要输入用户名和密码，第 3 个仅指定了远程的目录，文件名字不变，第 4 个指定了文件名</p>
<blockquote>
<p>如果要把远程的拷贝到本地，把第一个路径使用远程的格式即可，如：<br><code>scp remote_username@remote_ip:remote_folder local_file</code></p>
</blockquote>
<ol start="2">
<li>拷贝目录<br>命令格式：<br><code>scp -r local_folder remote_username@remote_ip:remote_folder</code><br>或者<br><code>scp -r local_folder remote_ip:remote_folder</code></li>
</ol>
<p>第 1 个指定了用户名，命令执行后需要输入用户密码；<br>第 2 个没有指定用户名，令执行后需要输入用户名和密码；</p>
<h3 id="远程连接中文乱码"><a href="#远程连接中文乱码" class="headerlink" title="远程连接中文乱码"></a>远程连接中文乱码</h3><ol>
<li>查看本地编码<br>在终端输入<code>locale</code></li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">LANG=<span class="string">"zh_CN.UTF-8"</span></span><br><span class="line">LC_COLLATE=<span class="string">"zh_CN.UTF-8"</span></span><br><span class="line">LC_CTYPE=<span class="string">"zh_CN.UTF-8"</span></span><br><span class="line">LC_MESSAGES=<span class="string">"zh_CN.UTF-8"</span></span><br><span class="line">LC_MONETARY=<span class="string">"zh_CN.UTF-8"</span></span><br><span class="line">LC_NUMERIC=<span class="string">"zh_CN.UTF-8"</span></span><br><span class="line">LC_TIME=<span class="string">"zh_CN.UTF-8"</span></span><br><span class="line">LC_ALL=</span><br></pre></td></tr></table></figure>

<p>但是我两台 mac 的编码是完全一样的，只是一个是 mac air ，一个是 mac pro，pro 连接 air 显示没问题，air 连接 pro 汉字乱码。</p>
<h3 id="乱码解决"><a href="#乱码解决" class="headerlink" title="乱码解决"></a>乱码解决</h3><p>在 pro 机器上，也就是远程的机器上执行如下命令：<br>在终端输入：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">vim ~/.zshrc</span><br></pre></td></tr></table></figure>

<p>添加如下内容</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">export</span> LC_ALL=en_US.UTF-8</span><br><span class="line"><span class="built_in">export</span> LANG=en_US.UTF-8</span><br></pre></td></tr></table></figure>

<p>接着重启一下终端，或者输入 <code>source ~/.zshrc</code> 使设置生效</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">source</span> ~/.zshrc</span><br></pre></td></tr></table></figure>

<h3 id="说明"><a href="#说明" class="headerlink" title="说明"></a>说明</h3><p>其实还是会受到带宽的影响，我的最多就是 8M 左右，最大的网速，但如果是一个不联网的局域网不知道会不会更快，得到飞鸽的那种上 G 的速度</p>
</div></article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:undefined">wenmu</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="http://blog.wangpengpeng.site/2020/02/28/%E4%B8%A4%E4%B8%AAmac%E4%B9%8B%E9%97%B4%E5%BF%AB%E9%80%9F%E4%BC%A0%E9%80%92%E6%96%87%E4%BB%B6/">http://blog.wangpengpeng.site/2020/02/28/%E4%B8%A4%E4%B8%AAmac%E4%B9%8B%E9%97%B4%E5%BF%AB%E9%80%9F%E4%BC%A0%E9%80%92%E6%96%87%E4%BB%B6/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank" rel="noopener">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="http://blog.wangpengpeng.site">温木的博客</a>！</span></div></div><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/%E7%94%B5%E8%84%91%E6%8A%80%E8%83%BD/">电脑技能</a></div><div class="post-qr-code"><div class="post-qr-code-item"><img class="post-qr-code__img" src="https://i.loli.net/2020/02/27/hOBzIxFDJMCrmtN.jpg"><div class="post-qr-code__desc">微信打赏</div></div></div><nav id="pagination"><div class="prev-post pull-left"><a href="/2020/02/28/JavaScript%E5%AE%9E%E7%8E%B0%E9%93%BE%E8%A1%A8/"><i class="fa fa-chevron-left">  </i><span>JavaScript实现链表</span></a></div><div class="next-post pull-right"><a href="/2020/02/25/%E5%93%8D%E5%BA%94%E5%BC%8F%E5%BC%80%E5%8F%91-1/"><span>响应式开发-1</span><i class="fa fa-chevron-right"></i></a></div></nav><div id="vcomment"></div><script src="https://cdn1.lncld.net/static/js/3.0.4/av-min.js"></script><script src="https://cdn.jsdelivr.net/npm/valine/dist/Valine.min.js"></script><script>var notify = 'false' == true ? true : false;
var verify = 'false' == true ? true : false;
var GUEST_INFO = ['nick','mail','link'];
var guest_info = 'nick,mail,link'.split(',').filter(function(item){
  return GUEST_INFO.indexOf(item) > -1
});
guest_info = guest_info.length == 0 ? GUEST_INFO :guest_info;
window.valine = new Valine({
  el:'#vcomment',
  notify:notify,
  verify:verify,
  appId:'U1QqpeQNuBnRsfygHk1GQ30q-gzGzoHsz',
  appKey:'dunDQzEseDzgsKgw4qLQcog1',
  placeholder:'支持markdown！',
  avatar:'wavatar',
  guest_info:guest_info,
  pageSize:'20',
  lang: 'zh-cn'
})</script></div></div><footer><div class="layout" id="footer"><div class="copyright">&copy;2019 - 2020 By wenmu</div><div class="framework-info"><span>驱动 - </span><a href="http://hexo.io" target="_blank" rel="noopener"><span>Hexo</span></a><span class="footer-separator">|</span><span>主题 - </span><a href="https://github.com/Molunerfinn/hexo-theme-melody" target="_blank" rel="noopener"><span>Melody</span></a></div><div class="busuanzi"><script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script><span id="busuanzi_container_page_pv">该文访问量<span id="busuanzi_value_page_pv"></span><span></span></span></div></div></footer><i class="fa fa-arrow-up" id="go-up" aria-hidden="true"></i><script src="https://cdn.jsdelivr.net/npm/animejs@latest/anime.min.js"></script><script src="https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js"></script><script src="https://cdn.jsdelivr.net/npm/velocity-animate@latest/velocity.min.js"></script><script src="https://cdn.jsdelivr.net/npm/velocity-ui-pack@latest/velocity.ui.min.js"></script><script src="/js/utils.js?version=1.6.1"></script><script src="/js/fancybox.js?version=1.6.1"></script><script src="/js/sidebar.js?version=1.6.1"></script><script src="/js/copy.js?version=1.6.1"></script><script src="/js/fireworks.js?version=1.6.1"></script><script src="/js/transition.js?version=1.6.1"></script><script src="/js/scroll.js?version=1.6.1"></script><script src="/js/head.js?version=1.6.1"></script><script>if(/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) {
  $('#nav').addClass('is-mobile')
  $('footer').addClass('is-mobile')
}</script></body></html>